var dns = require('dns');
const { hostname } = require('os');
/*
dns.lookup('www.baidu.com', 4,function onLookup(err, address, family) {
   console.log('lookup;','ip 地址:', err, address);
});

//使用 getnameinfo 解析传入的地址和端口为域名和服务。
dns.lookupService('127.0.0.1', 80, (err, hostname, service) => {
    console.log('lookupService;',err,hostname, service);
});

//将一个域名（如 'www.baidu.com'）解析为一个 rrtype 指定记录类型的数组。
dns.resolve('www.baidu.com',(err,addresses) =>{
  console.log('resolve;',err,addresses)
});

//根据ip地址解析对应域名。
dns.reverse('127.0.0.1',(err,hostname)=>{
    console.log('reverse;',err,hostname)
})
*/
//设置dns服务器  The setServers method affects only resolve,dns.resolve*() and reverse (and specifically not lookup)
dns.setServers(['127.0.0.1:53535']);
let dnsServers = dns.getServers();
dns.resolve('something.domain.com',(err,addresses) =>{
    console.log('resolve;',err,addresses)
  });
